package two.chapter_1.c1_2;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;

public class Ex1_2_1 {

    public static void main(String [] args){
        int N=100;
        Point2D[] ps=new Point2D[N];
        for (int i=0;i<N;i++){
            double x=StdRandom.uniform();
            double y=StdRandom.uniform();
            Point2D p=new Point2D(x,y);
            //p.draw();
            ps[i]=p;
        }

        double min=Double.MAX_VALUE;
        for (int i=0;i<N;i++){
            for (int j=i+1;j<N;j++){
                double distance=ps[i].distanceTo(ps[j]);
                if (distance<min){
                    min=distance;
                }

            }
        }
        StdOut.println("最小值："+min);
    }
}
